﻿using System;
using TFramework.ECS.Collection;
using TFramework.ECS.Component;
using TFramework.ECS.Entity;
using TFramework.ECS.Group;
using TFramework.ECS.System;
using TFramework.Extensions;
using UniRx;
using UnityEngine;
using VContainer;

public class TestSyetem : ISetupSystem,IUpdateSystem
{
    [Inject]
    private IEntityCollection entityCollection;

    public IGroup Group => new Group(typeof(ComponentTest), typeof(ViewComponent));

    public void Setup(IEntity entity)
    {
        Observable.Timer(TimeSpan.FromSeconds(3f)).Subscribe(_ =>
        {
            ViewComponent view = entity.GetComponent<ViewComponent>();
            GameObject.Destroy(view.View as GameObject);
            entityCollection.RemoveEntity(entity.Id);
        });
    }

    public void Update(IEntity entity)
    {
        Debug.Log("update");
    }
}
